<template>
  <div id="dashboard">
    <div id="top">
      <Row>
        <Col span="5" offset="1">
          <Card id="ban1">
            <Row justify="space-between">
              <Col span="6">日期</Col>
              <Col span="6">天气</Col>
              <Col span="6">最低温度</Col>
              <Col span="6">最高温度</Col> </Row
            ><br />
            <Row justify="space-between">
              <Col span="6">{{date}}</Col>
              <Col span="6">{{info.type}}</Col>
              <Col span="6">{{info.low}}</Col>
              <Col span="6">{{info.high}}</Col>
            </Row>
          </Card>
        </Col>
        <Col span="5" offset="1">
          <Card id="ban1">
            <Row justify="space-between">
              <Col span="6">客户</Col>
              <Col span="6">准客户</Col>
              <!-- <Col span="6">离开客户</Col>
              <Col span="6">供应商</Col></Row -->
              </Row
            ><br />
            <Row justify="space-between">
              <Col span="6">{{cus.ccount}}</Col>
              <Col span="6">{{cus.mcount}}</Col>
              <!-- <Col span="6">9</Col>
              <Col span="6">-26</Col> -->
            </Row>
          </Card>
        </Col>
        <Col span="5" offset="1">
          <Card id="ban1">
            <Row justify="space-between">
              <Col span="6">现有库存</Col>
              <Col span="6">临期库存</Col>
               <Col span="6">需进货仓库</Col>
               <Col span="6">现有量</Col>
              </Row
            ><br />
            <Row justify="space-between">
              <Col span="6">{{store_info.tv}}</Col>
              <Col span="6">{{store_info.lq}}</Col>
              <Col span="6" v-if="store_info.nstore">{{store_info.nstore[0]}}</Col>
              <Col span="6" v-if="store_info.nstore">{{store_info.nstore[1]}}</Col>
            </Row>
          </Card>
        </Col>

        <Col span="5" offset="1">
          <Card id="ban1">
            <Row justify="space-between"><Col span="6">订单数</Col>
              <Col span="6">需进货作物</Col>
              <Col span="6">现有量</Col>
              <!-- <Col span="6">需处理作物</Col> </Row -->
              </Row
            ><br />
            <Row justify="space-between">
              <Col span="6">{{crop_info.orders}}</Col>
              <Col span="6" v-if="crop_info.crop">{{crop_info.crop[0]}}</Col>
              <Col span="6" v-if="crop_info.crop">{{crop_info.crop[1]}}</Col>
              <!-- <Col span="6">黄豆</Col> -->
            </Row>
          </Card>
        </Col> </Row
      ><br />
    </div>

    <div class="demo-split">
      <Split v-model="split1">
        <div slot="left" class="demo-split-pane">
          <ckreli :datas="datas1"></ckreli>
        </div>
        <div slot="right" class="demo-split-pane">
          <Col span="24">
            <Card id="tubiao">
              <ckpie :datas="datas2"></ckpie>
            </Card>
          </Col>

          <Col span="24" >
            <Card id="tubiao">
              <ckpie2 title="收入前七名" :datas="datas3"></ckpie2>
            </Card>
          </Col>
          <!-- <Col span="24">
            <Card id="tubiao"> 
              <ckline> </ckline>
            </Card>
          </Col> -->

          <Button id="blxi" @click="value1 = true" type="primary"
            >联系我们</Button
          >
          <Drawer
            title="欢迎您的建议"
            :closable="false"
            v-model="value1"
            width="400"
          >
            <div id="jianyi">
              <p style="color: #607d8b; font-size: 200%">联系我们</p>
              <br />
              <p style="color: #607d8b; font-size: 150%">
                您有什么意见，请告诉我们：
              </p>
              <br />

              <Form
                ref="formValidate"
                :model="formValidate"
                :rules="ruleValidate"
              >
                <FormItem prop="name">
                  <Input
                    v-model="formValidate.name"
                    placeholder="请输入您的姓名："
                  ></Input>
                </FormItem>
                <FormItem prop="mail">
                  <Input
                    v-model="formValidate.mail"
                    placeholder="请输入您的邮箱："
                  ></Input>
                </FormItem>

                <FormItem prop="desc">
                  <Input
                    v-model="formValidate.desc"
                    type="textarea"
                    :autosize="{ minRows: 10, maxRows: 10 }"
                    placeholder="请输入您的建议："
                  ></Input>
                </FormItem>

                <FormItem>
                  <Button
                    id="submit"
                    type="primary"
                    @click="handleSubmit('formValidate')"
                    >提交</Button
                  >
                  <Button id="reset" @click="handleReset('formValidate')"
                    >重置</Button
                  >
                </FormItem>
              </Form>
            </div>
          </Drawer>
        </div>
      </Split>
    </div>
  </div>
</template>

<script>
import ckpie from "../chart/ck_pie";
import ckpie2 from "../chart/ck_pie2";
import ckreli from "../chart/ck_reli";
// import ckbar from "../chart/ck_bar"
// import ckline from "../chart/ck_line";

export default {
  data() {
    return {
      split1: 0.78,
      value1: false,
      date: "",
      info:{},
      cus:{},
      store_info:{},
      crop_info:{},
      datas1: {},
      datas2: [],
      datas3: [],
      formValidate: {
        name: "",
        mail: "",
      },
      ruleValidate: {
        name: [
          {
            required: true,
            message: "名字不能为空",
            trigger: "blur",
          },
        ],
        mail: [
          {
            required: true,
            message: "邮箱不能为空",
            trigger: "blur",
          },
          { type: "email", message: "Incorrect email format", trigger: "blur" },
        ],
        desc: [
          {
            required: true,
            message: "请输入您的建议",

            trigger: "blur",
          },
          {
            type: "string",
            min: 20,

            message: "建议不能少于20字哦",
            trigger: "blur",
          },
        ],
      },
    };
  },
  components: {
    ckpie,
    ckpie2,
    ckreli,
    // ckbar,
    // ckline,
  },
  mounted() {
    var today = new Date();
    var y = today.getFullYear();
    var m = today.getMonth() + 1;
    var d = today.getDate();
    m = m < 10 ? "0" + m : m;
    d = d < 10 ? "0" + d : d;
    this.date = y + "-" + m + "-" + d;
    var url = "http://wthrcdn.etouch.cn/weather_mini?city=天津";
    this.axios
      .get(url)
      .then((r) => {
        this.info = r.data.data.forecast[0];
      })
      .catch((e) => {
        this.$Message.error("e" + e);
      });

    this.axios
      .get("/api/")
      .then((r) => {
        // this.x = r.data.store;
        // this.y = r.data.crop;
        this.datas1 = { x: r.data.store, y: r.data.crop, data: r.data.data };
        this.datas2 = r.data.pie;
        this.datas3 = r.data.rose;
        this.cus=r.data.cus
        this.store_info=r.data.store_info
        this.crop_info=r.data.crop_info
      })
      .catch((e) => {
        this.$Message.error("e" + e);
      });
  },
  methods: {
    handleSubmit(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.$Message.success("Success!");
        } else {
          this.$Message.error("Fail!");
        }
      });
    },
    handleReset(name) {
      this.$refs[name].resetFields();
    },
  },
};
</script>

<style >
#top {
  margin-top: 20px;
}
.demo-split {
  height: 720px;
  margin-left: 25px;
  border: 1px solid #dddce2;
}
.demo-split-pane {
  padding: 10px;
}
#ban1 {
  border-radius: 10px;
  background-color: #a9afbb;
}

#lianxi {
  margin-left: 260px;
}
#jianyi {
  width: 350px;
  height: 600px;
  background-color: #e8eaec;
  padding: 20px;
  font: 12px/150% "微软雅黑", Arial, serif;
  color: #f5f7f9;
  font-family: "微软雅黑";
}
#submit {
  width: 100px;
  text-align: center;
  height: 40px;
  line-height: 30px;
  color: #fff;
  font-size: 20px;
  margin-left: 80px;
  background: #607d8b;
}

#reset {
  width: 100px;
  text-align: center;
  height: 40px;
  line-height: 30px;
  color: #fff;
  font-size: 20px;
  margin-left: 10px;
  background: #607d8b;
}
#blxi {
  background-color: black;
  margin-top: 1px;
  margin-left: 300px;
}
#tubiao {
  border-radius: 10px;
}
</style>
